<?php

require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if ($CURUSER["class"] < UC_MODERATOR && $CURUSER['id'] != $betsadmin)
	stderr("错误", "权限不足");
if (empty($_POST['heading']) || empty($_POST['undertext']) || empty($_POST['endtime'])) {
	stderr('傻狍子', '请输入竞猜标题或名称或结束时间');
}
$heading = htmlspecialchars($_POST['heading']);
$heading = str_replace("'", "", $heading);
$undertext = htmlspecialchars($_POST['undertext']);
$undertext = str_replace("'", "", $undertext);
//$endtime = (int) $_POST['endtime'] + time();
$endtime = strtotime($_POST['endtime']);
$sort = (int) $_POST['sort'];
sql_query("INSERT INTO betgames(heading, undertext, endtime, sort, creator) VALUES(" . sqlesc($heading) . ", " . sqlesc($undertext) . ", " . sqlesc($endtime) . ", " . sqlesc($sort) . ", '$CURUSER[id]')") or sqlerr(__FILE__, __LINE__);
header("location: bet_admin.php");
